package sy.po;

import java.util.List;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.ColType;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

/**
 * 
 * @author 孙宇
 *
 */
@Table("t_user")
@Comment("用户表")
public class User extends BaseModel {

	@Column
	@Comment("登录名")
	@ColDefine(width = 100, notNull = true)
	private String name;

	@Column
	@Comment("密码")
	@ColDefine(width = 40, notNull = true)
	private String pwd;

	@Column
	@Comment("年龄")
	@ColDefine(type = ColType.INT)
	private Integer age;

	// 一对一关联，一个用户属于一个公司
	@Column
	@Comment("公司主键")
	private String companyId;
	@One(field = "companyId", target = Company.class)
	private Company company;// 公司对象

	// 角色集合，多对多关联，一个用户可以有多个角色，一个角色也可以属于多个用户
	@ManyMany(from = "userId", relation = "t_user_role", target = Role.class, to = "roleId")
	private List<Role> roles;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getCompanyId() {
		return companyId;
	}

	public void setCompanyId(String companyId) {
		this.companyId = companyId;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

}
